<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="org.apache.shiro.web.filter.authc.FormAuthenticationFilter"%>
<%@ page import="org.apache.shiro.authc.ExcessiveAttemptsException"%>
<%@ page import="org.apache.shiro.authc.IncorrectCredentialsException"%>
<%@ include file="/WEB-INF/common/includes.jsp"%>

<!DOCTYPE html>
<html>
<head>
<title>zzzzzz - Login</title>
<%@ include file="/WEB-INF/common/meta.jsp"%>
<%@ include file="/WEB-INF/common/global_res.jsp"%>
<script type="text/javascript" src="${ctx}/res/jquery/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="${ctx}/res/jquery/validate/messages_zh_CN.js"></script>
<script type="text/javascript">
	$(function() {
		$('#loginForm').validate({
			rules : {
				username : {
					required : true,
					email : true
				},
				password : {
					minlength : 6,
					required : true
				}
			},
			highlight : function(label) {
				$(label).closest('.control-group').addClass('error');
			},
			success : function(label) {
				$(label).closest('.control-group').addClass('success');
			}
		});
	});
</script>
</head>
<body>

	<%@ include file="/WEB-INF/common/header.jsp"%>

	<div class="container">
		<div class="row">
			<div class="span2">&nbsp;</div>
			<div class="span8">
				<form id="loginForm" action="${ctx}/login" method="post" class="form-horizontal">
					<%
						String error = (String) request.getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME);
						if (error != null) {
					%><div class="alert alert-error">
						<i class='icon-warning-sign'></i>&nbsp;<%
							if ("org.apache.shiro.authc.IncorrectCredentialsException".equals(error)) {
						%>您的帐号密码不正确，请重试。<%
							} else if ("com.zzzzzz.account.signin.UserActiveException".equals(error)) {
						%>您的帐号未激活，请激活后再登录，谢谢。<%
							} else {
						%>登录失败，请重试。<%
							}
						%>
					</div>
					<%
						}
					%>

					<div class="control-group">
						<label for="username" class="control-label">邮箱:</label>
						<div class="controls">
							<input type="text" id="username" name="username"
								value="${username}" class="input-medium required" />
						</div>
					</div>
					<div class="control-group">
						<label for="password" class="control-label">密码:</label>
						<div class="controls">
							<input type="password" id="password" name="password"
								class="input-medium required" />
						</div>
					</div>

					<div class="control-group">
						<div class="controls">
							<label class="checkbox" for="rememberMe">
								<input type="checkbox" id="rememberMe" name="rememberMe" />记住我
							</label> 
							<input id="submit_btn" class="btn btn-primary" type="submit" value="登录" />
							<a class="btn" href="${ctx}/signup">注册</a>
						</div>
					</div>
				</form>
			</div>
			<div class="span2">&nbsp;</div>
		</div>
	</div>

	<%@ include file="/WEB-INF/common/footer.jsp"%>

</body>
</html>